package top.lixunda.ecommerce.server.good.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.lixunda.common.utils.ObjectValidators;
import top.lixunda.ecommerce.server.business.BaseServiceImpl;
import top.lixunda.ecommerce.server.business.api.entity.vo.ImageUploadTokenVO;
import top.lixunda.ecommerce.server.good.api.entity.db.StorePictureDO;
import top.lixunda.ecommerce.server.good.mapper.StorePictureMapper;
import top.lixunda.ecommerce.server.good.service.IStorePictureService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 店铺图片相关 服务实现类
 * </p>
 *
 * @author Xumda
 * @since 2019-12-18
 */
@Service
public class StorePictureServiceImpl extends BaseServiceImpl<StorePictureMapper, StorePictureDO> implements IStorePictureService {

    /**
     * 根据图片id获取图片信息
     *
     * @param id 图片保存的id
     * @return 图片信息
     */
    @Override
    public StorePictureDO queryById(Integer id) {
        if (ObjectValidators.isEmpty(id)) {
            throw getAppException("图片id不能为空");
        }
        return getById(id);
    }

    /**
     * 根据商品id获取图片信息
     *
     * @param id 图片保存的id
     * @return 图片信息
     */
    @Override
    public List<StorePictureDO> queryByStoreId(Integer id) {
        if (ObjectValidators.isEmpty(id)) {
            throw getAppException("店铺id不能为空");
        }
        return list(new LambdaQueryWrapper<StorePictureDO>()
                .eq(StorePictureDO::getStoreId, id));
    }

    /**
     * 申请上传商品图片的token
     *
     * @return 上传商品图片的token
     */
    @Override
    public ImageUploadTokenVO createUploadToken() {
        return null;
    }

}
